intro to ASM: l5 Division
This level focuses on register operations, particularly division. Values in registers will change dynamically, requiring formulaic operations. Results are typically stored in rax.
x86 uses integer math, where all values are whole numbers. For example, 10 / 3 = 3, as 3.33 is rounded down.
Key instructions: mov rax, reg1; div reg2
The div instruction divides a 128-bit dividend by a 64-bit divisor, storing both quotient and remainder. It operates as follows:
rax = rdx:rax / reg
rdx = remainder
Here, rdx:rax represents a 128-bit dividend, with rdx as the upper 64 bits and rax as the lower 64 bits.
Exercise: Compute speed = distance / time
distance = rdi
time = rsi
speed = rax
Note: distance is at most 64 bits, so set rdx to 0 before dividing.
Initial register values:
rdi = 0x18d3
rsi = 0x5c
sol:
for personal reference..



